<!DOCTYPE html>
<html>

	<head>
		<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="../../css/iuapmobile.um.css">
		<link rel="stylesheet" href="../../css/font-icons.css">
		<link rel="stylesheet" href="../../css/iscroll.css" />
		<style>
			.select_dummy {
				border: none;
				padding-left: 10px;
				color: #555;
				font-size: 14px;
				text-align: right;
				margin-right: 20px;
				width: 100%;
			}
			
			.select_dummy:disabled {
				background: #fff;
			}
		</style>
		<script src="../../js/summer.js"></script>
		<script src="../../js/jquery.min.js"></script>
		<script src="../../js/Frameworks/iuapmobile.frameworks.ui.js"></script>
		<script src="../../js/iscroll.js"></script>
		<script src="../../js/angular.min.js"></script>
	</head>

	<body class="f14" ng-app="myApp" ng-controller="myCtrl">
		<!--um-win-->
		<div class="um-page" id="repairinstalled">
			<div class="um-header">
				<a href="#" class="um-back back"> 返回 </a>
				<h3>维修派工详情</h3>
			</div>
			<div class="um-content">
				<ul class="um-list">
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									报修人员
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bbxry}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									所属部门
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bssbm}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									报修时间
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bbxsj}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									设备编号
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bsbbh}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									资产编号
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bzcbh}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									点位号
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bdwh}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									商家经营名称
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bsjjymc}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									商家经营地址
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bsjjydz}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									负责人
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bfzr}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									负责人联系方式1
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bfzrlxfs1}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									近景照
								</div>
								<div class="um-list-item-right">
									<img id="mtz1" ng-model="data.bjjz" ng-src="{{data.bjjz}}" class="h50 p5 lookimg" />
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									近景照（地址）
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bjjzdz}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									故障描述
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bgzms}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									故障照片
								</div>
								<div class="um-list-item-right">
									<img id="mtz1" ng-model="data.bgzzp" ng-src="{{data.bgzzp}}" class="h50 p5 lookimg" />
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									故障照片（地址）
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bgzzpdz}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									预留照片1
								</div>
								<div class="um-list-item-right">
									<img id="mtz1" ng-model="data.bylzp1" ng-src="{{data.bylzp1}}" class="h50 p5 lookimg" />
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									预留照片1（地址）
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bylzp1dz}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									预留照片2
								</div>
								<div class="um-list-item-right">
									<img id="mtz1" ng-model="data.bylzp2" ng-src="{{data.bylzp2}}" class="h50 p5 lookimg" />
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									预留照片2（地址）
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bylzp2dz}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									预留照片3
								</div>
								<div class="um-list-item-right">
									<img id="mtz1" ng-model="data.bylzp3" ng-src="{{data.bylzp3}}" class="h50 p5 lookimg" />
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									预留照片3（地址）
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bylzp3dz}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									预留照片4
								</div>
								<div class="um-list-item-right">
									<img id="mtz1" ng-model="data.bylzp4" ng-src="{{data.bylzp4}}" class="h50 p5 lookimg" />
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									预留照片4（地址）
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bylzp4dz}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									预留照片5
								</div>
								<div class="um-list-item-right">
									<img id="mtz1" ng-model="data.bylzp5" ng-src="{{data.bylzp5}}" class="h50 p5 lookimg" />
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									预留照片5（地址）
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bylzp5dz}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									照片是否地址
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bzpsfdz == "Y" ? "是":"否"}}</span>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="um-list-item">
							<div class="um-list-item-inner">
								<div class="um-list-item-left pl5">
									现场核查时间
								</div>
								<div class="um-list-item-right">
									<span class="form-control tr">{{data.bxchcsj}}</span>
								</div>
							</div>
						</div>
					</li>
				</ul>
			</div>
			<div class="um-footer">
				<a href="#page2" id="changepage2"></a>
				<button class="um-btn" onclick="page1_2()">
					填报派工信息
				</button>
			</div>
		</div>

		<div class="um-page" id="page2">
			<div class="um-header">
				<a href="#" class="um-back"> 返回 </a>
				<h3>填报派工信息</h3>
			</div>
			<div class="um-content">
				<ul class="um-list">
					<li class="um-list-item">
						<div class="um-list-item-inner">
							<div class="um-list-item-left pl5">
								<span class="um-red">*</span>故障判定类型
							</div>
							<div class="um-list-item-right">
								<select ng-model="js_gzpdlx" id='js_gzpdlx' class="select">
									<option ng-repeat="x in guzhangleixin" value="{{x.pk_doc}}">{{x.doc_name}}</option>
								</select>
							</div>
						</div>
					</li>
					<li class="um-list-item">
						<div class="um-list-item-inner">
							<div class="um-list-item-left pl5">
								<span class="um-red">*</span>故障判定描述
							</div>
							<div class="um-list-item-right">
								<select ng-model="js_gzpdms" id='js_gzpdms' class="select">
									<option ng-repeat="x in guzhangmiaoshu" value="{{x.pk_doc}}">{{x.doc_name}}</option>
								</select>
							</div>
						</div>
					</li>
					<li class="um-list-item">
						<div class="um-list-item-inner">
							<div class="um-list-item-left pl5">
								<span class="um-red">*</span>是否委外
							</div>
							<div class="um-list-item-right">
								<label class="um-switch2 um-box-vc ">
                                	<input type="checkbox" class="um-switch2" id="js_sfwy" ng-model="js_sfwy" ng-checked="js_sfwy" />
                                    <span class="um-switch2-check" data-on-text="是" data-off-text="否"  style="margin-right: 0px; "></span>
								</label>
							</div>
						</div>
					</li>
					<li class="um-list-item sfww">
						<div class="um-list-item-inner">
							<div class="um-list-item-left pl5">
								委外维修对象
							</div>
							<div class="um-list-item-right">
								<span class="form-control tr" style="display: none;">{{data.js_wywxdx}}</span>
								<span class="form-control tr">{{data.js_wywxdx_text}}</span>
							</div>
						</div>
					</li>
					<li class="um-list-item">
						<div class="um-list-item-inner">
							<div class="um-list-item-left pl5">
								<span class="um-red">*</span>故障判定照片
							</div>
							<div class="um-list-item-right">
								<img id="js_gzpdzp" ng-model="js_gzpdzp" onclick="openCamera(this,pageid)" ng-src="{{js_gzpdzp}}" class="h50 p5 camera" />
							</div>
						</div>
					</li>
					<li class="um-list-item">
						<div class="um-list-item-inner">
							<div class="um-list-item-left pl5">
								<span class="um-red">*</span>是否需领用配件
							</div>
							<div class="um-list-item-right">
								<label class="um-switch2 um-box-vc ">
                                	<input type="checkbox" class="um-switch2" id="js_sfxlypj" ng-model="js_sfxlypj" ng-checked="js_sfxlypj" />
                                    <span class="um-switch2-check" data-on-text="是" data-off-text="否"  style="margin-right: 0px; "></span>
								</label>
							</div>
						</div>
					</li>
					<li class="um-list-item lysb">
						<div class="um-list-item-inner">
							<div class="um-list-item-left pl5">
								<span class="um-red">*</span>需使用备件名称
							</div>
							<div class="um-list-item-right">
								<select ng-model="js_xsybjmc" id='js_xsybjmc' class="select" multiple="multiple">
									<option ng-repeat="x in peijianmingcheng" value="{{x.pk_doc}}">{{x.doc_name}}</option>
								</select>
							</div>
						</div>
					</li>
					<li class="um-list-item lysb">
						<div class="um-list-item-inner">
							<div class="um-list-item-left pl5">
								<span class="um-red">*</span>需使用备件数量
							</div>
							<div class="um-list-item-right">
								<input type="number" class="form-control tr" placeholder="请填写" ng-model="js_xsybjsl" required>
							</div>
						</div>
					</li>

				</ul>
			</div>
			<div class="um-footer">
				<button class="um-btn" onclick="page2_submit()">
					提交
				</button>
			</div>
		</div>
	</body>

</html>

<script>
	var angularScope; //anglajs
	var pageParam; //打开当前页的参数
	var changeObj; //根据单号加载的数据 修改
	var pageid = "repairinstalled";

	function GuZhangLeiXin() {
		doPost(adressHead.ISjtzImpl, "getBdDoc", {
			dataParm: {
				dostype: "app022_pid"
			}
		}, function(jsons) {
			angularScope.guzhangleixin = jsons;
			angularScope.$apply();
		}, null, true);
	}

	function GuZhangMiaoShu(leixin) {
		doPost(adressHead.ISjtzImpl, "getBdDoc", {
			dataParm: {
				dostype: "app022_" + leixin
			}
		}, function(jsons) {
			angularScope.guzhangmiaoshu = jsons;
			angularScope.$apply();
		}, null, true);
	}

	function PeiJianMingCheng() {
		doPost(adressHead.ISjtzImpl, "getBdDoc", {
			dataParm: {
				dostype: "app023"
			}
		}, function(jsons) {
			angularScope.peijianmingcheng = jsons;
			angularScope.$apply();
		}, null, true);
	}

	function GongYingShang(pp) {
		if(!pp) { alerts("暂无品牌信息 "); return; }
		doPost(adressHead.IMaintenanceImpl, "getSupplier", {
			dataParm: {
				name: pp
			}
		}, function(jsons) {
			angularScope.data.js_wywxdx_text = jsons.data[0].name;
			angularScope.data.js_wywxdx = jsons.data[0].pk_supplier;
			angularScope.$apply();
		}, null, true);
	}

	$("input").change(function() {
		switch(this.id) {
			case "js_sfxlypj":
				setTimeout(function() {
					//PeiJianMingCheng();//下拉状态不清空bug，手动重绑定
					if(angularScope.js_sfxlypj) {
						$(".lysb").show();
					} else {
						$(".lysb").hide();
					}
				}, 100);
				break;
			case "js_sfwy":
				setTimeout(function() {
					if(angularScope.js_sfwy) {
						$(".sfww").show();
					} else {
						$(".sfww").hide();
					}
				}, 100);
				break;
		}
	});
	$('.select').change(function() {
		$("#" + $(this).attr("id") + "_dummy").val($(this).find("option:selected").text());
		switch(this.id) {
			case "js_gzpdlx":
				$("#js_gzpdms_dummy").val("请选择");
				angularScope.js_gzpdms = [];
				angularScope.$apply();
				setTimeout(function() { GuZhangMiaoShu(angularScope.js_gzpdlx); }, 110);
				break;
			case "js_xsybjmc":
				setTimeout(function() {
					//显示加逗号
					var aa = "";
					for(var i = 0; i < angularScope.js_xsybjmc.length; i++) {
						aa += ("," + $("#js_xsybjmc option[value='" + angularScope.js_xsybjmc[i] + "']").text());
					}
					aa = aa.substring(1);
					$("#js_xsybjmc_dummy").val(aa);
					angularScope.js_xsybjsl = angularScope.js_xsybjmc.length;
					angularScope.$apply();

				}, 100);
				break;
		}

		//无选择时，改为请选择
		var thiss = this;
		if(!$(this).find("option:selected").text()) {
			setTimeout(function() {
				$("#" + $(thiss).attr("id") + "_dummy").val("请选择");
			}, 110);
		}
	});

	summerready = function() {
		try { pageParam = summer.pageParam; } catch(e) {}
		GuZhangLeiXin();
		PeiJianMingCheng();
		$(".lysb").hide();
		//pageParam = {"bsbbh":"BAC004045","bzcbh":"170118","bdwh":"2017041801-1","bsjjymc":"麻辣小龙虾","bsjjydz":"天府三街","bpk":"1001A810000000019I4O"};
		doPost(adressHead.IMaintenanceImpl, "getCard3", {
			dataParm: {
				bpk: pageParam.bpk
			}
		}, function(jsons) {
			angularScope.data = jsons.data;
			angularScope.$apply();
			GongYingShang(jsons.data.bsbpp);
		});
	}

	var app = angular.module('myApp', []);
	app.controller('myCtrl', function($scope, $http) {
		angularScope = $scope;
		$("#js_sfwy").trigger("change");
	});

	//第一步确认按钮
	var json1;

	function page1_2() {
		$("#changepage2").click();
	}
	//第二部提交按钮 
	function page2_submit() {
		if(!angularScope.js_gzpdlx) {
			toasts("请选择故障类型");
			return;
		}
		if(!angularScope.js_gzpdms) {
			toasts("请选择故障描述");
			return;
		}
		if(!imgs["js_gzpdzp"]) {
			toasts("请拍摄故障判定照片");
			return;
		}
		UM.confirm({
			title: '友情提示:',
			text: '确认要提交到服务器吗？',
			btnText: ["取消", "提交"],
			overlay: true,
			ok: function() {
				page2_submit2();
			},
			cancle: function() {}
		});
	}

	function page2_submit2() {
		var js_xsybjmcs = "";
		if(angularScope.js_xsybjmc) {
			for(var i = 0; i < angularScope.js_xsybjmc.length; i++) {
				js_xsybjmcs += ("," + angularScope.js_xsybjmc[i]);
			}
			js_xsybjmcs = js_xsybjmcs.substring(1);
		}
		//请求数据
		doPost(adressHead.IMaintenanceImpl, "updateWxpg", {
			dataParm: {
				bpk: pageParam.bpk,
				js_gzpdlx: angularScope.js_gzpdlx || "",
				js_gzpdms: angularScope.js_gzpdms || "",
				js_sfwy: angularScope.js_sfwy == true ? "Y" : "N",
				js_wywxdx: angularScope.js_sfwy == true && angularScope.data.js_wywxdx ? angularScope.data.js_wywxdx : "",
				js_gzpdzp: imgs["js_gzpdzp"] || "",
				js_sfxlypj: angularScope.js_sfxlypj == true ? "Y" : "N",
				js_xsybjmc: angularScope.js_sfxlypj == true ? js_xsybjmcs : "",
				js_xsybjsl: angularScope.js_sfxlypj == true ? Number(angularScope.js_xsybjsl) : 0,
			}
		}, function(jsons) {
			if(jsons.result == 1) {
				toasts("提交成功");
				summer.execScript({
					winId: 'repair2',
					script: "rebind()"
				});
				summer.closeWin();
			} else {
				toasts("提示：" + jsons.msg);
			}
		});
	}
	//相机打开
	var imgs = new Array();

	function openCamera(obj) {
		summer.openCamera({
			compressionRatio: summer.getSysInfo().systemType == "android" ? 1 : 0.7,
			callback: function(args) {
				UM.showLoadingBar({
					text: "请稍等",
					icons: 'ti-reload',
				});
				//args.imgPath   args.compressImgPath
				getBase64Image(args.compressImgPath, function(dat) {
					summer.openWin({
						id: "rotateImg",
						url: "html/all/rotateImg.html",
						isKeep: true,
						pageParam: {
							id: obj.id, //编号
							base64: dat, //base64
							pageId: "shangjiatuozhan" //page ID
						}
					});
					setTimeout(function() {
						UM.hideLoadingBar();
					}, 2000);
				}, 1);
			}
		});
	}
	var imgObj = "";

	function rotateBack(dat, index) {
		imgObj += dat;
		if(index == 4) {
			try {
				var obj = JSON.parse(imgObj);
				document.getElementById(obj.id).src = obj.base64;
				imgs[obj.id] = obj.base64;
			} catch(e) {}
		}
	}

	//下拉框样式
	$(function() {
		var opt = {
			'date': {
				preset: 'date'
			},
			'select': {
				preset: 'select'
			}
		};
		$('.select').scroller('destroy').scroller($.extend(opt['select'], {
			theme: "ios7",
			mode: "scroller",
			display: "bottom",
			animate: ""
		}));
		$('.select').each(function(a, b) {
			$("#" + b.id + "_dummy").addClass("select_dummy");
			$("#" + b.id + "_dummy").val("请选择");
		});

		$("img.camera").attr("src", "../../img/myimg/camera.png");
	});
</script>

<script src="../../js/Myjs/Common.js"></script>